'''from .models import TestpaperResult, UserCourseScore

def extract_and_calculate_scores():
user_course_scores = {}

testpaper_results = TestpaperResult.objects.all()
for result in testpaper_results:
    key = (result.userId, result.courseId)
    if key not in user_course_scores:
        user_course_scores[key] = {
            'userId': result.userId,
            'courseId': result.courseId,
            'score': 0.0
        }

    user_course_scores[key]['score'] += result.score

# 将整合后的数据保存到 UserCourseScore 模型中
for key, value in user_course_scores.items():
    UserCourseScore.objects.update_or_create(
        userId=value['userId'],
        courseId=value['courseId'],
        defaults={'score': value['score']}
    )'''


